
import {repayAccountType} from "./config"

/****
 * code和status 转换
 */
export default {
	filters: {
		$_parseTime(time, cFormat) {
			if (arguments.length === 0) {
				return null;
			}
			if (time === undefined || time === null)
				return '';

			const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}';
			let date;
			if (typeof time == 'object') {
				date = time;
			} else {
				if (('' + time).length === 10) time = parseInt(time) * 1000;

				date = new Date(time);
			}
			const formatObj = {
				y: date.getFullYear(),
				m: date.getMonth() + 1,
				d: date.getDate(),
				h: date.getHours(),
				i: date.getMinutes(),
				s: date.getSeconds(),
				a: date.getDay()
			};
			const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
				let value = formatObj[key];
				if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1];
				if (result.length > 0 && value < 10) {
					value = '0' + value;
				}
				return value || 0;
			});
			return time_str;
		},
		$_changeTime(time) {
			let newtime = '';
			newtime = time.substring(0, 4) + '-' + time.substring(4, 6) + '-' + time.substring(6, 8) + ' ' + time.substring(8, 10) + ':' + time.substring(10, 12) + ':' + time.substring(12, 14)
			return newtime
		},
		$_repayAccountType: (value) => {
			return repayAccountType[value] || ""
		}
	}
}


